package lc.暴力;

/**
 * 长度最小的子数组
 *
 * @author yang
 * @date 2021/12/26
 */
public class 长度最小的子数组 {

    public int minSubArrayLen(int target, int[] nums) {

        int min = Integer.MAX_VALUE;
        int len = 0;
        for (int i = 0; i < nums.length; i++) {
                int x = 0;
            for (int j = i; j < nums.length; j++) {
                x += nums[j];
                if (x >= target) {
                    len = j - i + 1;
                    min = min < len ? min : len;
                    break;
                }
            }
        }
        return min;
    }
}
